﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using r4u.business.logic.layer.REGISTER;
using r4u.Models;

namespace r4u.Controllers
{
    public class PaymentController : Controller
    {
        //
        // GET: /Payment/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Index2()
        {
            return View();
        }


        public ActionResult ValidateCommand(string product, string totalPrice)
        {
            bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["IsSandbox"]);
            var paypal = new PayPalModel(useSandbox);

            paypal.item_name = product;
            paypal.amount = totalPrice;
            paypal.@return = paypal.@return + "?product=" + product;

            return View(paypal);
        }


        public ActionResult RedirectFromPaypal(string product)
        {
            User user = new User();
            string email = HttpContext.User.Identity.Name;

            switch (product)
            {
                case "30 Day Trial":
                    user.ActivateTrial(email);
                    break;
                case "R4U Monthly Subscription":
                    user.ActivateMonthlySubscription(email);
                    break;
                case "R4U Annual Subscription":
                    user.ActivateAnnualSubscription(email);
                    break;
            }
            return View();
        }

        public ActionResult CancelFromPaypal()
        {
            return View();
        }

    }
}
